﻿import flash.external.*

function ready()
{
	ExternalInterface.call("t_ui.begin");
}
btn_ready.addEventListener("click", this, "ready");
function quit()
{
	ExternalInterface.call("t_ui.exit");
}
btn_quit.addEventListener("click", this, "quit");

//初始化排列元件
var cmp_list:Array = new Array();	// 元件列表
var init_pos:Array = new Array(); // 初始化位置
function init_cmp()
{
	cmp_list.splice(0,card_cmp_list.length); //清空
	for(i = 0; i < init_pos.length; i+=2)
	{
		posx = init_pos[i];
		posy = init_pos[i+1];
		cname = "cp_pos"+i
		cpc = _root.attachMovie("cp_pos", cname, i);  //由库中的元件创建
		cpc._x = posx;             //x坐标
		cpc._y = posy; 
		cpc._visible = false
		cmp_list.push(cpc);
	}
}
//设置显示信息
function set_info(i:Number, nickname:String, score:Number)
{
	cpc = cmp_list[i];
	cpc.txt_name.text = nickname;	//昵称
	cpc.txt_score.text = score;		//分数
	cpc.bimg.disabled = true;		//准备指示灯
	cpc.bimg.visible = true;
	cpc.lb_master._visible = false;
	cpc.btn_out.addEventListener("click", 
		function ()
		{
			ExternalInterface.call("t_ui_ready.getout",i);
		});	//踢出按钮
	//cpc.btn_change.addEventListener("click", 
		//function ()
		//{
			//ExternalInterface.call("t_ui_ready.change_seat",i);
		//});	//更换座位
	//更换座位2
	cpc.pos_bg.onPress = (function ()
		{
			ExternalInterface.call("t_ui_ready.change_seat",i);
		});	
}
//隐藏元件
function hide_info(i:Number)
{
	cpc = cmp_list[i];
	cpc.txt_name.text = "[无人]"
	cpc.txt_score.text = "0"
	cpc.btn_out.visible = false;
	cpc.bimg.visible = false;
	cpc.bimg.disabled = true;
	cpc.lb_master._visible = false;
	//cpc._visible = false
}
//显示房主操作按钮
function show_trbtn(i:Number, v:Boolean)
{
	cpc = cmp_list[i];
	cpc.btn_out.visible = v;
}
//换座位按钮
function show_change_seat(i:Number, v:Boolean)
{
	//cpc = cmp_list[i];
	//cpc.btn_change.visible = v;
}
//房主标识
function show_master_lable(i:Number, v:Boolean)
{
	cpc = cmp_list[i];
	cpc.lb_master._visible = v;
}
//变更准备指示灯的显示
function change_ready(i:Number, v:Boolean)
{
	cpc = cmp_list[i];
	if (v)
	{
		cpc.bimg.disabled = false;
	}
	else
	{
		cpc.bimg.disabled = true;
	}
}
//设置控件显示
function set_open(i:Number, v:Boolean)
{
	cpc = cmp_list[i];
	cpc._visible = v;
}